package org.example;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.math.BigDecimal;
import java.util.List;

@Mapper
public interface ProductMapper extends BaseMapper<Product> {

    // 自定义查询方法
    @Select("SELECT * FROM product WHERE name = #{name}")
    List<Product> selectByName(@Param("name") String name);

    // 其他自定义查询、更新、删除方法
    @Select("SELECT * FROM product WHERE price >= #{minPrice} AND price <= #{maxPrice}")
    List<Product> selectByPriceRange(@Param("minPrice") BigDecimal minPrice, @Param("maxPrice") BigDecimal maxPrice);
    @Update("UPDATE product SET price = #{newPrice} WHERE id = #{id}")
    int updatePriceById(@Param("id") Long id, @Param("newPrice") BigDecimal newPrice);
    @Delete("DELETE FROM product WHERE id = #{id}")
    int deleteById(@Param("id") Long id);


}
